
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpServicesProvider } from "../../providers/http-services/http-services";
import { UtilsProvider } from "../../providers/utils/utils";
import { ValidateProvider } from "../../providers/validate/validate";
import { ConfigProvider } from "../../providers/config/config";
/**
 * Generated class for the ReBuyListPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage({
  segment: 're-buy-list',
  defaultHistory: ['HomePage','ReBuyPage', ]
})
@Component({
  selector: 'page-re-buy-list',
  templateUrl: 're-buy-list.html',
})
export class ReBuyListPage {
  token: string;
  searchParams = {};
  page=1;  
  tasks = [];
  constructor(
    public navCtrl: NavController, 
    public httpService: HttpServicesProvider,
    public config: ConfigProvider,
    public validate: ValidateProvider,
    public util: UtilsProvider,
    public navParams: NavParams) {
  }

  ionViewDidLoad() {
    this.token = this.config.getToken();
    this.getData();
    this.getData()
  }
          /**
       * 页面加载获取数据
       * */
      getData() {
        //获取任务信息列表
        let params = {
          token: this.token,
          page:this.page
        };
        Object.assign(params, this.searchParams);

        let loading = this.util.loading();
        loading.show();
        this.httpService.requestPostData('/mul_mission/my_re_buy_list', params, response => {
          loading.close()
          this.page++
          if (response['error'] == 200) {
            this.tasks = response['data']['lists'];
            //全部数据
          } else {
            this.util.presentAlert(response.message);
          }
        });
      }
      pageRedirect(page,data={}){
        let loading = this.util.loading();
        loading.show();
        this.navCtrl.push(page,data).then(success=>{
            loading.close();
            if(success !== true){//页面需要登录后跳转
                this.navCtrl.push('LoginPage',data);
            }
        })
    }
}
